/**this app is used to read file */
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<unistd.h>
#include<stdlib.h>
int main(void){
	int fd,ret;
	char buf[1024]={0};
	memset(buf,0x0,sizeof(buf));
	fd=open("./test.txt",O_RDONLY);
	if(-1==fd){
		printf("open error\n");
		return 1;
	}
	printf("open OK\n");
	ret=read(fd,buf,sizeof(buf));
	if(-1==ret){
		printf("write error\n");
		close(fd);
		return 1;
	}
	printf("read %d bytes\n",ret);
	printf("%s\n",buf);
	close(fd);
	return 0;
}
